#include <iostream>
#include <assert.h>

using namespace std;

class Date
{
    friend istream& operator>>(istream& in, Date& d);
    friend ostream& operator<<(ostream& out, const Date& d);
public:
    Date(int year = 1, int month = 1, int day = 1)
        :_year(year)
         ,_month(month)
         ,_day(day)
    { assert(CheckDate()); }

    int GetMonthDay(int year, int month)
    {
        static int MonthDay[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
        if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
            return 29;
        else 
            return MonthDay[month];
    }

    bool CheckDate()
    {
        if (_year >= 1 && _month >= 1 && _month <= 12 && _day >= 1 && _day <= GetMonthDay(_year, _month))
            return true;
        else 
            return false;
    }

    bool operator==(const Date& d) const ;
    bool operator!=(const Date& d) const ;
    
    bool operator<(const Date& d) const ;
    bool operator<=(const Date& d) const ;
    bool operator>(const Date& d) const ;
    bool operator>=(const Date& d) const ;

    Date operator+(int day);
    Date& operator+=(int day);
    Date operator-(int day);
    Date& operator-=(int day);

    Date& operator++();
    Date operator++(int);
    Date& operator--();
    Date operator--(int);

    int operator-(const Date& d);

private:
    int _year;
    int _month;
    int _day;
};

inline ostream& operator<<(ostream& out, const Date& d)
{
    out << d._year << '-' << d._month << '-' << d._day;
    return out;
}

inline istream& operator>>(istream& in, Date& d)
{
    in >> d._year >> d._month >> d._day;
    assert(d.CheckDate());

    return in;   
}
